package com.sskj.common.util;

import android.content.Context;
import android.support.v4.content.ContextCompat;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.sskj.common.R;
import com.sskj.common.base.App;

public class TipMineUtil {
    public static MaterialDialog getTip(Context context, String content, OnTipSure onTipSure) {
        return getTip(context, content, App.INSTANCE.getString(R.string.common_sure), onTipSure);
    }

    public static MaterialDialog getTip(Context context, String content, String sureMsg, OnTipSure onTipSure) {
        return new MaterialDialog.Builder(context)
                .negativeColor(ContextCompat.getColor(context,R.color.commonTextFFF))
                .positiveColor(ContextCompat.getColor(context,R.color.commonTextFFF))
                .title(App.INSTANCE.getString(R.string.common_hint))
                .content(content)
                .positiveText(sureMsg)
                .negativeText(App.INSTANCE.getString(R.string.common_cancel))
                .onAny((dialog, which) -> {
                    if (which == DialogAction.POSITIVE) {
                        dialog.dismiss();
                        onTipSure.onSure();
                    } else if (which == DialogAction.NEGATIVE) {
                        dialog.dismiss();
                    }
                }).build();
    }

    public static MaterialDialog getTip(Context context, String title, String content, String sureMsg, OnTipSure onTipSure) {
        return new MaterialDialog.Builder(context)
                .title(title)
                .content(content)
                .positiveText(sureMsg)
                .negativeText(App.INSTANCE.getString(R.string.common_cancel))
                .onAny((dialog, which) -> {
                    if (which == DialogAction.POSITIVE) {
                        dialog.dismiss();
                        onTipSure.onSure();
                    } else if (which == DialogAction.NEGATIVE) {
                        dialog.dismiss();
                    }
                }).build();
    }

    public interface OnTipSure {
        void onSure();
    }

}
